package pointandlinejicheng;

public class LineSub extends Point {
	private double x1;
	private double y1;
	private Point end;

	public LineSub() {
		super();
	}

	public LineSub(double x, double y, double x1, double y1) {
		super(x, y);
		this.x1 = x1;
		this.y1 = y1;
		this.end = new Point(x, y);
	}

	public LineSub(Point begin, Point end) {
		super(begin.getX(), begin.getY());
		this.end = end;
	}

	public double getX1() {
		return x1;
	}

	public void setX1(double x1) {
		this.x1 = x1;
	}

	public double getY1() {
		return y1;
	}

	public void setY1(double y1) {
		this.y1 = y1;
	}

	public Point getEnd() {
		return end;
	}

	public void setEnd(Point end) {
		this.end = end;
	}

	public Point getBegin() {
		return new Point(x1, y1);
	}

	public void setBegin(double x1, double y1) {
		this.x1 = x1;
		this.y1 = y1;
	}

	public double getLength() {
		double len = (end.getX() - x1) * (end.getX() - x1) + (end.getY() - y1) * (end.getY() - y1);
		// System.out.println(end.getX());
		// System.out.println(end.getY());
		// System.out.println(x1);
		// System.out.println(y1);
		return Math.sqrt(len);
	}

	public double getGradient() {
		return Math.abs(end.getY() - y1) / Math.abs(end.getX() - x1);
	}
}
